package com.lb.shopguide.ui.view;

import android.content.Context;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lb.shopguide.R;

/**
 * Created by kang on 2018/1/9.
 * 较为清爽的顶部栏
 */

public class ClearTitleBar extends RelativeLayout {
    private Context context;

    private ImageView ivLeft;
    private TextView tvLeft;
    private TextView tvTitle;

    public ClearTitleBar(Context context) {
        super(context);
        this.context = context;
    }

    public ClearTitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        View view = LayoutInflater.from(context).inflate(R.layout.bar_clean, this);
        ivLeft = view.findViewById(R.id.image_left);
        tvLeft = view.findViewById(R.id.tv_left);
        tvTitle = view.findViewById(R.id.tv_title);
    }

    public void setLeftText(String string) {
        tvLeft.setText(string);
        tvLeft.setVisibility(VISIBLE);
    }


    /**
     * 左图标
     *
     * @param id
     */
    public void setLeftImageSrc(int id) {
        ivLeft.setVisibility(View.VISIBLE);
        ivLeft.setImageResource(id);
    }


    public void setTvTitle(String string) {
        tvTitle.setText(string);
        tvTitle.setVisibility(VISIBLE);
    }

    /*
    * 点击事件
    */
    public void setOnLeftImageListener(OnClickListener listener) {
        ivLeft.setOnClickListener(listener);
    }

    public void setOnLeftTextListener(OnClickListener listener) {
        tvLeft.setOnClickListener(listener);
    }
}
